home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / SymantecBeanDescriptor.java < prev    next >
Text File  |  1998-08-21  |  6KB  |  183 lines

  1. package symantec.itools.beans;
  2.  
  3. import java.beans.*;
  4. import java.util.Vector;
  5.  
  6.  
  7. //  06/06/97    CAR Created
  8. //  06/10/97    CAR Added final static fields to be used by BeanDescriptor.setValue
  9. //  06/11/97    LAB Changed name of innerclass from "ConnectionDescriptor" to "Descriptor"
  10. //                    because of the 31 character limit on the Mac.
  11. //  07/01/97    CAR No longer implements the Connections interface
  12. //                  getConnectionDescriptors now returns an array of ConnectionDescriptor
  13. //                  changed add to addConnectionDescriptor
  14. //  08/15/97    CAR added call to setValue in constructor
  15. //  08/27/97    CAR added method addAdditionalConnections to get BeanDescriptor connections
  16. //                  from super classes
  17.  
  18. /**
  19.  * Extension to java.beans.BeanDescriptor that implements methods for specifying
  20.  * Visual CafΘ integration information for a bean.  Such as the Visual CafΘ toolbar
  21.  * tab name for this bean, Visual CafΘ Interaction Wizard information, etc.
  22.  *
  23.  * @version 1.0, June 6, 1997
  24.  *
  25.  * @author  Symantec
  26.  *
  27.  */
  28. public class SymantecBeanDescriptor extends BeanDescriptor {
  29.  
  30.     /**
  31.      * A constant that specifies the "can add a child" key.
  32.      */
  33.     public static final String CAN_ADD_CHILD    = "CAN_ADD_CHILD";
  34.     /**
  35.      * A constant that specifies the "flags" key.
  36.      */
  37.     public static final String FLAGS            = "FLAGS";
  38.     /**
  39.      * A constant that specifies the "folder" key.
  40.      */
  41.     public static final String FOLDER           = "FOLDER";
  42.     /**
  43.      * A constant that specifies the "toolbar" key.
  44.      */
  45.     public static final String TOOLBAR          = "TOOLBAR";
  46.     /**
  47.      * A constant that specifies the "winhelp" key.
  48.      */
  49.     public static final String WINHELP          = "WINHELP";
  50.     /**
  51.      * A constant that specifies root template 
  52.      */
  53.     public static final String ROOTTEMPLATE     = "ROOTTEMPLATE";
  54.  
  55.     /**
  56.      * Constructs a SymantecBeanDescriptor for a bean class.
  57.      * @param beanClass the class of the bean
  58.      */
  59.     public SymantecBeanDescriptor(Class beanClass) {
  60.  
  61.         super(beanClass);
  62.         connections = new Vector();
  63.         setValue(ConnectionDescriptor.CONNECTIONS, connections);
  64.         setCanAddChild(true);
  65.     }
  66.  
  67.     /**
  68.      * Create a SymantecBeanDescriptor for a bean that has a customizer.
  69.      * @param beanClass  the class of the bean
  70.      * @param customizerClass  The class of the customizer 
  71.      */
  72.     public SymantecBeanDescriptor(Class beanClass, Class customizerClass) {
  73.         super(beanClass, customizerClass);
  74.         connections = new Vector();
  75.         setValue(ConnectionDescriptor.CONNECTIONS, connections);
  76.         setCanAddChild(true);
  77.     }
  78.         
  79.     /**
  80.      * Gets the ConnectionDescriptors for this bean class.
  81.      * @return an array of ConnectionDescriptors
  82.      */
  83.     public ConnectionDescriptor[] getConnectionDescriptors() {
  84.  
  85.         ConnectionDescriptor[] rv = new ConnectionDescriptor[connections.size()];
  86.         connections.copyInto(rv);
  87.  
  88.         return rv;
  89.     }
  90.  
  91.     /**
  92.      * Adds a ConnectionDescriptor to this bean class.  A ConnectionDescriptor defines
  93.      * an "Interaction Wizard" interaction for this bean.
  94.      * @param c the new ConnectionDescriptor
  95.      * @see symantec.itools.beans.ConnectionDescriptor
  96.      */
  97.     public void addConnectionDescriptor(ConnectionDescriptor c) {
  98.  
  99.         connections.addElement(c);
  100.     }
  101.  
  102.     /**
  103.      * Adds any ConnectionDescriptors to this BeanDescriptor which are
  104.      * associated with the BeanDescriptors of the BeanInfos in the array argument.
  105.      * @param bi a BeanInfo array typically returned from a call to
  106.      * BeanInfo.getAdditionalBeanInfo
  107.      */
  108.     public void addAdditionalConnections(BeanInfo[] bi) {
  109.  
  110.         SymantecBeanDescriptor sbd = null;
  111.         Vector v = null;
  112.         int i = 0;
  113.         while (i < bi.length && bi[i].getBeanDescriptor() instanceof SymantecBeanDescriptor) {
  114.             sbd = (SymantecBeanDescriptor) bi[i].getBeanDescriptor();
  115.             v = (Vector) sbd.getValue(ConnectionDescriptor.CONNECTIONS);
  116.             for (int j = 0; j < v.size(); ++j) {
  117.                 if(!connections.contains(v.elementAt(j)))
  118.                     connections.addElement(v.elementAt(j));
  119.             }
  120.             ++i;
  121.         }
  122.     }
  123.  
  124.     /**
  125.      * Sets the "can add a child" attribute.  Set to false if you have a
  126.      * bean that derives from java.awt.Panel, but you don't want to
  127.      * allow users to drop other components into this bean.
  128.      * @param b the new value of this attribute
  129.      */
  130.     public void setCanAddChild(boolean b) {
  131.         Boolean bObj = new Boolean(b);
  132.         setValue(CAN_ADD_CHILD, bObj);
  133.     }
  134.  
  135.     /**
  136.      * Sets the "flags" attribute.  Set to "INVISIBLE" for beans that
  137.      * do not have a visual representation at run time.
  138.      * @param f the new value of this attribute
  139.      */
  140.     public void setFlags(String f) {
  141.         setValue(FLAGS, f);
  142.     }
  143.  
  144.     /**
  145.      * Sets the "folder" attribute.  This is the name of the component library
  146.      * that will contain this bean.
  147.      * @param f the new value of this attribute
  148.      */
  149.     public void setFolder(String f) {
  150.         setValue(FOLDER, f);
  151.     }
  152.  
  153.     /**
  154.      * Sets the "toolbar" attribute.  This is the name of the toolbar tab that
  155.      * will contain this bean.
  156.      * @param t the new value of this attribute
  157.      */
  158.     public void setToolbar(String t) {
  159.         setValue(TOOLBAR, t);
  160.     }
  161.  
  162.     /**
  163.      * Sets the "winhelp" attribute.  A Windows help file may be specified for a
  164.      * bean.  However, the help file may not be jarred up with the bean.  The string for
  165.      * this attribute should specify a Windows help system ID number along with the name of the file
  166.      * where the help resides.  The ID and file name are seperated by a comma.
  167.      * @param h the new value of this attribute
  168.      */
  169.     public void setWinHelp(String h) {
  170.         setValue(WINHELP, h);
  171.     }
  172.  
  173.     /**
  174.      * Sets the "ROOTTEMPLATE" attribute.  
  175.      * @param h the new value of this attribute
  176.      */
  177.     public void setRootTemplate(String h) {
  178.         setValue(ROOTTEMPLATE, h);
  179.     }
  180.  
  181.     private Vector connections;
  182. }
  183.